<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

/**
* This controller is used for JAEmail feature of the component
*/
class JobBoardControllerJAEmployers extends JobBoardController {
/**
     * Constructor
     */
    function __construct()
    {    	
        parent::__construct();  
        $this->set('name', 'employers');
        $this->set('fullname', 'jaemployers');             
        // Register Extra tasks
        $this->registerTask( 'apply',   'save' );        
		$this->registerTask( 'unblock', 	'block');
    }
    
    /**
    * Display current jaemployers of the component to administrator
    * 
    */
    function display(){    	    	
		parent::display();
    }
    
    /**
	 * Edit content of email
	 *
	 * @return void
	 */
	function sendmail(){			    
	    global $option;
	    $temp = $this->getModel('jaemployers');
	    $emails = $temp->getEmails();
	    
	    $this->setRedirect("index.php?option=$option&view=jamail&emails=$emails");
	}
	
    /**
    * Cancel current operation
    * 
    */
    function cancel(){
    	global $option;
        $this->setRedirect("index.php?option=$option&view=jaemployers");
    }   
    /**
    * Remove a jaemployers row
    * 
    */   
    /*function remove(){
    	global $option;
 
    	// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );
        
        $model =& $this->getModel('jaemployers');
        if(($msg = $model->remove()) == ''){
             $this->setMessage(JText::sprintf('Items removed', $n));
		}
		
		$this->setRedirect("index.php?option=$option&view=jaemployers", $msg);
	}*/
		
	/**
	* Save categories record
	*/
	function save(){
		global $option;
		// Check for request forgeries
		//JRequest::checkToken() or jexit( 'Invalid Token' );
				
		$model	=& $this->getModel('jaemployers');
			
		if ($id = $model->store()) {
			$msg = JText::_( 'The Profile Saved' );
		} else {
			JError::raiseWarning(1, JText::_( 'Error Saving Profile item' ));
			$msg = '';
		}

		switch ( $this->_task ) {
			case 'apply':
				$this->setRedirect( "index.php?option=$option&view=jaemployers&task=profile&cid[]=$id" , $msg );
				break;			
			default:
				$this->setRedirect( "index.php?option=$option&view=jaemployers", $msg );
				break;
		}
	}
		
	       
}